/*
 * Created on 2006-2-10
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.page.ResultProcess;
import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.business.*;
import com.hitrust.gs.form.GSOperatorFuncQueryForm;
/**
 * @author simonyi
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GSOperatorFuncQueryAction extends GSBaseAction {

    public String execute(GSBaseForm aForm) throws Exception {
        
        GSOperatorBean operatorBean = (GSOperatorBean)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
        
        GSOrgProcessor processer = new GSOrgProcessor ();
        GSOrganizationProcessor orgp = new GSOrganizationProcessor();
        //if(aForm.getSession().getAttribute("organdaddr") == null){
            ArrayList ary = processer.getOperOrgAndSubOrg(operatorBean.getGs_oper_org_id());
            aForm.getSession().setAttribute("orglist",ary);
            ArrayList organdoper = orgp.getOrgAndOper();
            aForm.getRequest().setAttribute("organdoper",organdoper);
        //}

            GSOperatorFuncQueryForm tForm = (GSOperatorFuncQueryForm)aForm;

            GSOperatorBean aBean = new GSOperatorBean();
            aBean.setGs_oper_org_id(tForm.getOperorgid());
            aBean.setGs_oper_id(tForm.getOperid());
            aBean.setGs_oper_name(tForm.getOpername());
			aBean.setGs_key_word(tForm.getKeyWord());
            
            GSOperatorProcessor proc = new GSOperatorProcessor();
            ArrayList operlist = proc.queryOperator(aBean);

            ResultProcess tProc = new ResultProcess();
            tProc.setResult(operlist);
            
            tForm.getRequest().setAttribute("operator",tProc);
            aForm.getRequest().setAttribute("requery","false");
        return GSBaseConstants.FORWARD_SUCCESS;
    }
}
